/**
 * 是否有操作按钮权限的mixins
 */
import {hasPermission} from '@/permission/btn'
let HasBtn = {
  data () {
    return {
    }
  },
  created () {
  },
  methods: {
    handleListBtn ({btn, row}) {
      var trigger = {
        edit: (row) => {
          this.edit(row)
        },
        del: (row) => {
          this.del(row)
        },
        info: (row) => {
          this.info(row)
        }
      }
      return trigger[btn].apply(this, [row])
    }
  },
  computed: {
    showBtn () { // 当前路由的菜单高亮， 菜单的el-menu-item :index===meta.activeMenu
      const route = this.$route
      const { meta, path } = route
      if (meta.activeMenu) { // 注意这里很重要
        return hasPermission(meta.activeMenu)
      }
      return false
    }
    // showBtn (btn) {
    //   return hasPermission(btn)
    // }
  }
}
export default HasBtn
